
//Javascript like - facebook
(function(d, s, id) {	
	var js, fjs = d.getElementsByTagName(s)[0];
	if (d.getElementById(id)) return;
	js = d.createElement(s); js.id = id;
	js.src = "//connect.facebook.net/pt_BR/all.js#xfbml=1";
	fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));

$(document).ready(function () {
	$('.rangaki').click(function(){window.location.href='/restaurantes'});
	$('.adm').click(function(){window.location.href='/rk-admin'});
	$('.meu').click(function(){window.location.href='/meu'});
	$('.logout').click(function(){
    Rk.service('login', 'logout', null, function(data) {
          if(data){
            window.location.href='/';
          }
      });
  });
  $('.close').click(function(){Rk.FecharModal()});
});

    //Javascript like - facebook
    (function(d, s, id) { 
        var js, fjs = d.getElementsByTagName(s)[0];
        if (d.getElementById(id)) return;
        js = d.createElement(s); js.id = id;
        js.src = "//connect.facebook.net/pt_BR/all.js#xfbml=1";
        fjs.parentNode.insertBefore(js, fjs);
    }(document, 'script', 'facebook-jssdk'));

  
  //Twitter functions
  var actualTweet = 0;
  var json;
  var totalTweets = 0;
  function initTwitter(j){
    console.log("json = " + j);
    json = j;
    totalTweets = json.length - 1;
    changeTwitterMsg();
  }
  
  function changeTwitterMsg(){
    
    if(actualTweet > totalTweets) actualTweet = 0;
    $("#twitter_update_list").fadeOut(1000, function(){
      $("#twitter_update_list").html(json[actualTweet++].text).fadeIn(2000);
    });
    setTimeout(changeTwitterMsg, 10000);
  }
  
  $(function() {
    $.ajax({
      url: "https://api.twitter.com/1/statuses/user_timeline.json?include_entities=true&screen_name=rangaki&count=5",
      dataType: "jsonp",
      jsonpCallback: "initTwitter"
    });
  });